<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
    <script src="https://cdn.jsdelivr.net/npm/vue@2.6.10/dist/vue.js"></script>
</head>

<body>
    <div id="app">
        <!-- 基本数据类型 -->
        <button @click="hander">点击修改</button>
        <p>{{msg}}</p>

        <!-- 数组类型修改 -->
        <button @click="add">点击新增</button>
        <ul>
            <li v-for="item in person">{{item}}
                <!-- <button @click="del">点击删除</button> -->
            </li>
        </ul>

        <button @click="del">删除对象数据</button>
        <button @click="addObj">增加对象数据</button>
        <ul>
            <li v-for="value,key in obj" :key="item">{{key}}--{{value}}</li>
        </ul>
    </div>
    <script>
        Vue.config.productionTip = false;

        const vm = new Vue({
            el: "#app",
            data() {
                return {
                    msg: "hello",
                    person: ["AAA", "BBB", "CCC"],
                    obj: {
                        name: "laowang",
                        age: 18,
                        score: {
                            math: 100,
                            ch: 90,
                        },
                    }
                }
            },
            methods: {
                hander() {
                    // 可直接修改
                    this.$data.msg = "???"
                },
                add() {
                    this.person.unshift("DDD")
                },
                del() {
                    // this.$delete(this.obj, "age");
                    // Vue.delete(this.obj, "age");
                },
                addObj() {
                    this.$set(this.obj, "sex", "男");
                    // Vue.set(this.obj, "sex", "男");
                }
            },
        })
    </script>
</body>

</html>